package com.changgou.goods.dao;

import com.changgou.goods.pojo.Brand;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface BrandMapper extends Mapper<Brand> {

    /**
    * @Date: 11:24 2020/3/29
    * @Param: [cateName]
    * @return: java.util.List<com.changgou.goods.pojo.Brand>
    * @Description: 根据商品分类名称查询品牌列表
    **/

    /*
         WHERE c.name=#{name} ---> @Param("name") String cateName
     */
    //List<Brand> findByCateName(@Param("name") String cateName);

    @Select("SELECT a.* FROM tb_brand a JOIN tb_category_brand b ON a.id = b.brand_id " +
            "JOIN tb_category c ON c.id = b.category_id WHERE c.name=#{cateName}")
    List<Brand> findByCateName(String cateName);
}
